package com.ruoyi.manage.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.manage.domain.EventManage;
import com.ruoyi.manage.service.IEventManageService;
import com.ruoyi.common.utils.poi.ExcelUtil;

/**
 * 事件管理Controller
 * 
 * @author liuyangyang
 * @date 2025-06-01
 */
@RestController
@RequestMapping("/manage/eventmanage")
public class EventManageController extends BaseController
{
    @Autowired
    private IEventManageService eventManageService;

    /**
     * 查询事件管理列表
     */
    @PreAuthorize("@ss.hasPermi('manage:eventmanage:list')")
    @GetMapping("/list")
    public AjaxResult list(EventManage eventManage)
    {
        List<EventManage> list = eventManageService.selectEventManageList(eventManage);
        return success(list);
    }

    /**
     * 导出事件管理列表
     */
    @PreAuthorize("@ss.hasPermi('manage:eventmanage:export')")
    @Log(title = "事件管理", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, EventManage eventManage)
    {
        List<EventManage> list = eventManageService.selectEventManageList(eventManage);
        ExcelUtil<EventManage> util = new ExcelUtil<EventManage>(EventManage.class);
        util.exportExcel(response, list, "事件管理数据");
    }

    /**
     * 获取事件管理详细信息
     */
    @PreAuthorize("@ss.hasPermi('manage:eventmanage:query')")
    @GetMapping(value = "/{eventId}")
    public AjaxResult getInfo(@PathVariable("eventId") Long eventId)
    {
        return success(eventManageService.selectEventManageByEventId(eventId));
    }

    /**
     * 新增事件管理
     */
    @PreAuthorize("@ss.hasPermi('manage:eventmanage:add')")
    @Log(title = "事件管理", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody EventManage eventManage)
    {
        return toAjax(eventManageService.insertEventManage(eventManage));
    }

    /**
     * 修改事件管理
     */
    @PreAuthorize("@ss.hasPermi('manage:eventmanage:edit')")
    @Log(title = "事件管理", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody EventManage eventManage)
    {
        return toAjax(eventManageService.updateEventManage(eventManage));
    }

    /**
     * 删除事件管理
     */
    @PreAuthorize("@ss.hasPermi('manage:eventmanage:remove')")
    @Log(title = "事件管理", businessType = BusinessType.DELETE)
	@DeleteMapping("/{eventIds}")
    public AjaxResult remove(@PathVariable Long[] eventIds)
    {
        return toAjax(eventManageService.deleteEventManageByEventIds(eventIds));
    }
}
